<%@page language="java"	import="com.tansuosoft.discoverx.app.wechat.oa.OnDispatch,com.tansuosoft.discoverx.app.wechat.out.MessageOut,com.tansuosoft.discoverx.app.wechat.TokenValidator,com.tansuosoft.discoverx.app.wechat.Receiver"%>
<%
com.tansuosoft.discoverx.web.JSPContext jspContext = new com.tansuosoft.discoverx.web.JSPContext(pageContext);
jspContext.setNoCache();
String result = "ok";
String contentType="text/plain; charset=utf-8";
if(!TokenValidator.validate(request)){
	result="error";
}else{
	MessageOut messageOut=null;
	Receiver receiver=new Receiver(request);
	if(receiver.hasMessage() && (messageOut=receiver.receive(new OnDispatch()))!=null) {
		result=messageOut.toXmlMessage();
		contentType="text/xml; charset=utf-8";
	}else{
		result=request.getParameter(TokenValidator.PN_ECHOSTR);
	}
	if(result==null||result==null)result="ok";
	response.setContentType(contentType);
}
%><%=result%>